import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpException;
import cn.hutool.http.HttpUtil;

import java.util.Map;

/**
 * @author tanghailan
 * @date 2022-01-20 09:56:32
 * @description
 */
public class Queryhyfc365 {
  private static final String HY365_URL =
      "http://www.hyfc365.com/gov/index.php?m=index&a=search_beian";
  private static final String HY365_GET_IMG_URL = "http://www.hyfc365.com/index.php";

  public static void main(String[] args) {
    //
    Map<String, Object> formDataParamsMap = MapUtil.newHashMap(4);
    Map<String, Object> paramsMap = MapUtil.newHashMap(2);
    paramsMap.put("a", "code");
    paramsMap.put("time", Math.random());
    formDataParamsMap.put("BEIAN_COMPACT_CODE", "HY2020922975");
    formDataParamsMap.put("BEIAN_REALTYOWNER_CODE", "430426200009048310");
    formDataParamsMap.put("BEIAN_REALTYOWNER_NAME", "唐海岚");
    String resp = null;
    try {
      String verificationCode = HttpUtil.get(HY365_GET_IMG_URL, paramsMap);
      System.out.println(verificationCode);
      formDataParamsMap.put("esf_code_img", verificationCode);
      //        TimeUnit.SECONDS.sleep(1);
      //      resp =
      //          HttpUtil.createPost(HY365_URL)
      //              .header("Cookie", "PHPSESSID=37tjv3ktidigiv7uabs2ia0k30")
      //              .form(formDataParamsMap)
      //              .timeout(3000)
      //              .execute()
      //              .body();
      //      System.out.println(resp);
      //      JsonNode parse = JsonUtil.parse(resp);

    } catch (HttpException e) {
      System.out.println(e.getMessage());
    }
    //    String jsonString = JsonUtil.toJSONString(resp);
    //    System.out.println(jsonString);
  }
}
